package cn.tedu.shoot;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

public class Enemy {
    int x,y;
    int speed;
    static Image enemyImg;
    static Image[] enemyImgs = new Image[6];
    static {
        enemyImg = new ImageIcon("plane/flys.png").getImage();
        for (int i = 0; i < enemyImgs.length; i++) {
            enemyImgs[i] = new ImageIcon("plane/flys"+i+".png").getImage();
        }
    }
    public Enemy(){
        Random random = new Random();
        this.x = random.nextInt(ShootFrame.WIDTH)-this.enemyImg.getWidth(null);
        this.y = -this.enemyImg.getHeight(null);
        this.speed = random.nextInt(4)+1;
    }
    int index=0;
    public void moveAndStep(){
        this.y +=this.speed;
        int i = index++/10%enemyImgs.length;
        this.enemyImg=this.enemyImgs[i];
    }
//    //敌机发射子弹
//    public EmenyBullet shoot(){
//
//    }
//    //敌机伤害英雄机
//    public void hitHero(Hero hero){
//
//    }

}
